package  com.pcbly.web.business.crm;

/**
* @author carl.song
* Copyright (c) 2010 Lightsoft, International.
* All rights reserved.
*
*/

import java.util.HashMap;
import java.util.List;

import com.pcbly.web.persistence.crm.SendMsgLogDao;
import com.pcbly.web.persistence.table.ColumnDao;
import com.pcbly.web.bean.crm.SendMsgLogBean;
import com.pcbly.web.bean.table.ColumnBean;
import com.pcbly.web.business.BaseServiceImp;
import com.pcbly.web.components.hibernate.support.Page;
import com.pcbly.web.components.form.AbstractAnalyseCommonDataExt;
import com.pcbly.web.components.form.AnalyseCommonDataExtCreate;
import com.pcbly.web.components.form.AnalyseCommonDataExtEdit;
import com.pcbly.web.components.form.AnalyseCommonDataExtView;

 
public class SendMsgLogServiceImp extends BaseServiceImp<SendMsgLogBean> implements SendMsgLogService {
	 public SendMsgLogServiceImp() {
		super();
		// TODO Auto-generated constructor stub
	}
	private SendMsgLogDao sendMsgLogDao;
	
	private ColumnDao columnDao;

	public void setColumnDao(ColumnDao columnDao) {
		this.columnDao = columnDao;
	}
	
	public void setSendMsgLogDao(SendMsgLogDao sendMsgLogDao) {
		this.sendMsgLogDao = sendMsgLogDao;
	}
	
	@Override
	public SendMsgLogBean getSendMsgLogBeanById(String id) throws Exception {
		// TODO Auto-generated method stub
		return sendMsgLogDao.get(SendMsgLogBean.class,id);
	}
	
	@Override
	public void removeSendMsgLogBeanById(String id) throws Exception{
		sendMsgLogDao.removeSendMsgLogBeanById(id);
	}
	
	@Override
	public void removeSendMsgLogBeanByIds(String ids) throws Exception{
		sendMsgLogDao.removeSendMsgLogBeanByIds(ids);
	}
	
	
	@Override
	public SendMsgLogBean saveSendMsgLogBean(SendMsgLogBean crm) throws Exception{
		return sendMsgLogDao.saveSendMsgLogBean(crm);
	}
	
	@Override
	public SendMsgLogBean updateSendMsgLogBean(SendMsgLogBean crm) throws Exception{
		sendMsgLogDao.saveObject( crm);
		return crm;
	}
	public Page<SendMsgLogBean>  findSendMsgLogBeanByCond(SendMsgLogBean bean,
			Page<SendMsgLogBean> page, String orderByName, boolean asc)
			throws Exception{
		return sendMsgLogDao.findSendMsgLogBeanByCond(
				bean, page, orderByName, asc);
	}
	
	@Override
	public String findSendMsgLogBeanExtCreate(String tableName) throws Exception {
		// TODO Auto-generated method stub
		List<ColumnBean> columnList = columnDao
				.findColumnBeansByTableName(tableName);
		AbstractAnalyseCommonDataExt common = new AnalyseCommonDataExtCreate();
		common.setColumnList(columnList);
		return common.execute().toString();
	}

	@Override
	public String findSendMsgLogBeanExtEdit(String tableName, String id)
			throws Exception {
		// TODO Auto-generated method stub
		List<HashMap<String, String>> dataList = sendMsgLogDao
				.findCommnonDataBeanExt(tableName, id);
		List<ColumnBean> columnList = columnDao
				.findColumnBeansByTableName(tableName);
		AbstractAnalyseCommonDataExt common = new AnalyseCommonDataExtEdit();
		common.setDataList(dataList);
		common.setColumnList(columnList);
		return common.execute().toString();
	}

	@Override
	public String findSendMsgLogBeanExtView(String tableName, String id)
			throws Exception {
		// TODO Auto-generated method stub
		List<HashMap<String, String>> dataList = sendMsgLogDao
				.findCommnonDataBeanExt(tableName, id);
		List<ColumnBean> columnList = columnDao
				.findColumnBeansByTableName(tableName);
		AbstractAnalyseCommonDataExt common = new AnalyseCommonDataExtView();
		common.setDataList(dataList);
		common.setColumnList(columnList);
		return common.execute().toString();
	}

	@Override
	public void saveSendMsgLogBeanExt(String sql) throws Exception {
		// TODO Auto-generated method stub
		sendMsgLogDao.saveCommnonDataBeanExt(sql);
	}

	@Override
	public boolean getHasSendMsgLogBeanExtData(String tableName, String id)
			throws Exception {
		// TODO Auto-generated method stub
		return sendMsgLogDao.getHasCommnonDataBeanExt(tableName, id);
	}
}
